
import mongoose from 'mongoose'

const User = mongoose.model('User')

export async function addUser(email, password) {
  let user = new User({
    email,
    password
  })
  let data = await user.save()
  
  return {data}
}

export async function verifyLogin(email, password) {
  let match = false
  let user = await User.findOne({ email: email }).exec()
  console.log('user')
  console.log(user)
  if (user) {
    match = await user.comparePassword(password, user.password)
  } else {}
  
  return {
    match,
    user
  }
}